<template>
  <div class="feedbackManage">
    <el-empty v-if="!noData"
              description="您未有反馈记录.......">
      <el-button type="primary" plain @click="toFeedback">立即反馈</el-button>
    </el-empty>

    <el-table
        :data="feedTable"
        style="width: 100%"
        highlight-current-row
        stripe
        height="600"
        v-if="noData">
      <el-table-column
          label="序号"
          type="index">
        <template slot-scope="scope">
          {{scope.$index+1}}
        </template>
      </el-table-column>
      <el-table-column
          prop="feedQuestion"
          label="反馈问题"
      >
      </el-table-column>
      <el-table-column
          prop="feedDescription"
          label="反馈描述"
      >
      </el-table-column>
      <el-table-column
          prop="feedTime"
          label="反馈时间"
          sortable>
        <template slot-scope="scope">
          {{shortTime(scope.row.feedTime)}}
        </template>
      </el-table-column>
      <el-table-column
          prop="feedStatus"
          label="状态">
        <template slot-scope="scope">
          <span v-if="scope.row.feedStatus == 0"><el-tag type="info" size="small" color="">待回复</el-tag></span>
          <span v-else><el-tag type="success" size="small" color="">已处理</el-tag></span>
        </template>
      </el-table-column>
      <el-table-column
          prop="replyContent"
          label="回复">
      </el-table-column>
      <el-table-column
          label="操作"
          width="100">
        <template slot-scope="scope">
          <el-button type="text" size="small" @click="toFeedDetail(scope.row.replyId)">详情</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import {shortTime} from "../../../../utils/timeFormat";
import {getFeedByUserId} from "@/api/allApi";

export default {
  name: "FeedbackManage",
  data() {
    return {
      noData:false,
      feedTable:[],
      user:'',
    }
  },
  created() {
    this.user = JSON.parse(window.localStorage.getItem('access-user'))
  },
  methods:{
    shortTime,
    toFeedDetail(replyId){
      this.$router.push({
        path: "/userLayout/userBackground/userFeedReplyDetail/"+replyId,
      });
    },
    getFeedByUserId() {
      getFeedByUserId(this.user.userId).then(res=>{
        if (res.data.data) {
          if (res.data.data.length >0){
            this.noData = true
          }
          this.feedTable = res.data.data
        }
      })
    },
    toFeedback() {
      this.$router.push({
        path: "/userLayout/feedback",
      });
    },
  },
  mounted() {
    this.getFeedByUserId()

  }
}
</script>

<style scoped>

</style>